var player = null; 
var playerT : Transform = null;
var pPos : Vector3;
var duration : float = .0001;
var maxHeight : int;
var minHeight : int;
var randTime : int;
private var passedTime : float;
private var startTime : float;
private var startPoint : Vector3;
private var randValue : float;
var verticalSpeed = 100;
var horizontalSpeed = 30;
private var timeLeft;

function Start(){
  player = GameObject.Find("Player");
  playerT = player.transform;
  startPoint = transform.position;
  startTime = Time.time;
  randTime = 5;
  randValue = Random.value;
}

function Update () {
  pPos = playerT.position;
  //transform.position = Vector3.Lerp(transform.position, pPos, .001 * Time.time  );
  passedTime = Time.time - startTime;
  timeLeft = randTime - passedTime;
  print (timeLeft);
  print (randValue);
  print (transform.position.y);
  if (timeLeft > 0){
		if (randValue > .5){
			transform.Translate(0, 1 * Time.deltaTime * verticalSpeed, horizontalSpeed * Time.deltaTime );
			if (transform.position.y > maxHeight) { 
				randValue = .4;
			}
		}
		else {
			transform.Translate(0, -1 * Time.deltaTime * verticalSpeed, horizontalSpeed * Time.deltaTime );
			if (transform.position.y < minHeight) {
				randValue = .6;
			}
		}
  }
  else {
	startTime = Time.time;
	randvalue = Random.value;
  }
}

//toDo peform collision;

